home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lamstex / inputs / anynum.tex < prev    next >
Text File  |  1991-09-06  |  3KB  |  59 lines

  1. \catcode`\@=11
  2. \def\newcounter#1{\define#1{}%
  3.  \edef\next@{\def\noexpand#1{\futurelet\noexpand\next
  4.   \csname\exstring@#1@Z\endcsname}}\next@
  5.  \edef\next@{\def\csname\exstring@#1@Z\endcsname
  6.   {\global\advance\csname\exstring@#1@C\endcsname\@ne
  7.   {\csname\exstring@#1@F\endcsname\csname\exstring@#1@S\endcsname
  8.    {\csname\exstring@#1@P\endcsname\csname\exstring@#1@N\endcsname
  9.    {\noexpand\number\csname\exstring@#1@C\endcsname}%
  10.    \csname\exstring@#1@Q\endcsname}}%
  11.   \noexpand\ifx\noexpand\next\noexpand\label
  12.    \def\noexpand\next@\noexpand\label########1{{\noexpand\noexpands@
  13.     \xdef\noexpand\Thelabel@{\csname\exstring@#1@N\endcsname
  14.      {\noexpand\number\csname\exstring@#1@C\endcsname}}%
  15.     \xdef\noexpand\Thelabel@@@{\noexpand\number
  16.      \csname\exstring@#1@C\endcsname}%
  17.     \xdef\noexpand\Thelabel@@{\csname\exstring@#1@S\endcsname
  18.      {\csname\exstring@#1@P\endcsname
  19.      \csname\exstring@#1@N\endcsname
  20.      {\noexpand\number\csname\exstring@#1@C\endcsname}%
  21.      \csname\exstring@#1@Q\endcsname}}%
  22.     \xdef\noexpand\Thelabel@@@@{\csname\exstring@#1@P\endcsname
  23.      \csname\exstring@#1@N\endcsname
  24.      {\noexpand\number\csname\exstring@#1@C\endcsname}%
  25.      \csname\exstring@#1@Q\endcsname}}%
  26.     {\noexpand\locallabel@\noexpand\label{########1}}}%
  27.    \noexpand\else\let\noexpand\next@\relax\noexpand\fi\noexpand\next@}}\next@
  28.  \expandafter\newcount@\csname\exstring@#1@C\endcsname
  29.  \expandafter\let\csname\exstring@#1@N\endcsname\arabic
  30.  \expandafter\def\csname\exstring@#1@S\endcsname##1{##1\/}%
  31.  \expandafter\let\csname\exstring@#1@P\endcsname\empty
  32.  \expandafter\let\csname\exstring@#1@Q\endcsname\empty
  33.  \expandafter\def\csname\exstring@#1@F\endcsname{\rm}%
  34.  }
  35. \def\usecounter#1#2{\expandafter\ifx\csname\exstring@#1@Z\endcsname
  36.  \relax\Err@{\noexpand#1not created with \string\newcounter}\fi
  37.  \expandafter\let\csname\exstring@#1@@Z\endcsname\relax
  38.  \expandafter\let\csname\exstring@#1@@Z@\endcsname\relax
  39.  \edef\next@{\def\noexpand#2{\futurelet\noexpand\next
  40.   \csname\exstring@#1@@Z\endcsname}}\next@
  41.  \edef\next@{\def\csname\exstring@#1@@Z\endcsname{\noexpand\ifx
  42.   \noexpand\next\noexpand\label\def\noexpand\next@\noexpand\label
  43.    ########1{\csname\exstring@#1@@Z@\endcsname
  44.    {\noexpand#1\noexpand\label{########1}}\noexpand\FNSSP@}%
  45.    \noexpand\else\noexpand\ifx\noexpand\next
  46.    \noexpand"\def\noexpand\next@\noexpand"########1\noexpand"%
  47.     {\csname\exstring@#1@@Z@\endcsname{{\expandafter\noexpand
  48.    \csname\exstring@#1@F\endcsname
  49.    \let\noexpand\pre\expandafter\noexpand\csname\exstring@#1@P\endcsname
  50.    \let\noexpand\post\expandafter\noexpand\csname\exstring@#1@Q\endcsname
  51.    \let\noexpand\style\expandafter\noexpand\csname\exstring@#1@S\endcsname
  52.    \let\noexpand\numstyle\expandafter\noexpand\csname\exstring@#1@N\endcsname
  53.    ########1}}\noexpand\FNSSP@}\noexpand\else
  54.    \def\noexpand\next@{\csname\exstring@#1@@Z@\endcsname{\noexpand#1}%
  55.     \noexpand\FNSSP@}%
  56.    \noexpand\fi\noexpand\fi\noexpand\next@}}\next@
  57.   \expandafter\def\csname\exstring@#1@@Z@\endcsname}
  58. \catcode`\@=\active
  59.